package come.example.pagetransformer.transform

import android.support.v4.view.ViewPager
import android.util.Log
import android.view.View


class StackTransformer : ViewPager.PageTransformer {

    override fun transformPage(view: View, position: Float) {
        var pos = position
        if (position < 0) {
            view.translationX = -position * view.width
            view.translationZ = position

            val scale = (view.width + 40 * position) / view.width
            view.scaleY = scale
            view.scaleX = scale

            view.translationY = -position * 40
            Log.d(TAG, "<<< p = $position, pos = $pos, scale $scale, view ${view.hashCode()}")
        } /*else if (pos >= 0.9f) {
            view.alpha = 1 - (10 * pos - 9)
        } else if (pos < 0.9f) {
            view.alpha = 1.0f
        }*/
        Log.d(TAG, "<<< p = $position, pos = $pos")

    }

    companion object {
        private val TAG = StackTransformer::class.java.simpleName
    }
}
